const gulp=require('gulp');
const less=require('gulp-less');
const path=require('path');
const del=require('del');
const autoprefixer=require('gulp-autoprefixer');
const cleanCSS=require('gulp-clean-css');

gulp.task('clean',()=>{
	del.sync('./build');
});

gulp.task('less',()=>{
	console.log('less 开始工作啦')
	gulp.src('src/**/*.less')
		.pipe(less())
		.pipe(autoprefixer({
			browsers:['last 5 versions','Firefox>20']
		}))
		.pipe(cleanCSS())
 		.pipe(gulp.dest('build'));
});

gulp.task('default',['clean','less'],()=>{
	console.log('开始工作啦！')
});

gulp.task('watch',()=>{
	var watcher = gulp.watch('src/**/*', ['default']);
	watcher.on('change', (event)=> {
		console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
	});
})


// gulp.task('default',()=>{
// 	gulp.src(['src/**/*'])
// 		.pipe(gulp.dest('build'));
// });

